#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QWidget>
#include <QDir>
#include <QtGui/QDirModel>

class QComboBox;
class QLabel;
class QPushButton;
class QTableWidget;
class QTableWidgetItem;
#include "tlocalpathsqlmodel.h"


namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void on_browseButton_clicked();
    void on_findButton_clicked();
    void openFileOfItem(int row, int column);

    void on_actionAbout_activated();

    void on_actionAbout_QT_activated();

    void on_actionOpen_MovieBase_activated();

    void on_actionRefresh_all_files_hash_activated();

    void on_actionUpdate_local_path_activated();

    void on_actionRefresh_connection_activated();

private:
    Ui::MainWindow *ui;
    void createFilesTable();
    QStringList findFiles(const QStringList &files, const QString &text);
    void showFiles(const QStringList &files);
    QString getFileHash(QFile &file);
    void updateComboBox(QComboBox *comboBox);
    void displayFileLocalPathLikeInDb();
    void updateFileLocalPathInDb();
    bool MainWindow::FindFileAndDir( QString szDir,QStringList &files,QStringList &fileName);
    void setDataBase(QString dbfileName);
    bool createBase();
    int updateLocalPathHash(bool apdateAll);
    int updateLocalPathHashMovies(bool apdateAll);
    int updateLocalPathHashEpisodes(bool apdateAll);
    QString convertToUnicode(const char*s);
    QDir currentDir;
    QDirModel model;
    TLocalPathSqlModel LocalPathSqlModel;
    //QSqlDatabase Db;
    QString DbName;
    QMap<QString /*hash*/, int /*id*/> mapFileHashDbAll;
    QMap<QString /*hash*/, int /*id*/> mapFileHashDb;
    QMap<QString /*hash*/, QString /*local path*/> mapFileHashFnd;
    QMap<QString /*hash*/,QTableWidgetItem *> mapFileHashTableIndex;
    QString lastDirectory;
    QString lastBaseFileName;

};

#endif // MAINWINDOW_H
